﻿//$("input:submit, a, button", ".divbutton").button();

//    //hover states on the static widgets
$('.dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); },
					function() { $(this).removeClass('ui-state-hover'); }
				);

function CallAjax(urlx, parameter) {
    $.ajax({
        type: 'POST',
        url: urlx + parameter,
        contentType: 'application/json',
        dataType: 'json',
        data: '{}',
        success: function (data) {
            if (data.IsSuccess) {
                alert(data.Message);
            }
            else {
                alert(data.Message);
            }
        },
        error: function () {
            alert('Error!');
        }
    });
}

function CallAjax(urlx, parameter, data) {
    $.ajax({
        type: 'POST',
        url: urlx + parameter,
        contentType: 'application/json',
        dataType: 'json',
        data: data,
        success: function(data) {
            if (data.IsSuccess) {
                alert(data.Message);
            }
            else {
                alert(data.Message);
            }
        },
        error: function() {
            alert('Error!');
        }
    });
}


/* New Added */

$(function () {
    var pickerOpts = {
        dateFormat: "dd-M-yy"
        //            changeMonth: true,
        //            changeYear: true
    };
    $(".clsDateTimePicker").attr("readonly", "readonly");
    $(".clsDateTimePicker").datepicker(pickerOpts);
    $(".edcDateTimePicker").datepicker(pickerOpts);
});

$(function () {
    $(".clsYear").datepicker({
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,

        beforeShow: function (input, inst) {
            var x;
            var date = $(this).val();
            if (date != '') {
                x = $.datepicker.parseDate('dd-M-yy', '1-jan-' + date);
                if (x != '') {
                    var dateFormat = $.datepicker.formatDate('MM', x);
                    $(this).val(dateFormat);
                    $(this).datepicker("setDate", x);
                }
            }
        },

        onClose: function (dateText, inst) {
            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
            var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            $(this).val($.datepicker.formatDate('yy', new Date(year, month, 1)));
        }
    });

    $(".clsYear").focus(function () {
        $(".ui-datepicker-calendar").hide();
        $("#ui-datepicker-div .ui-datepicker-month").hide();
        $("#ui-datepicker-div").position({
            my: "center top",
            at: "center bottom",
            of: $(this)
        });

        try {
            var x;
            var date = $(this).val();
            if (date != '') {
                x = $.datepicker.parseDate('mm/dd/yy', date);
                if (x != '') {
                    var dateFormat = $.datepicker.formatDate('yy', x);
                    $(this).val(dateFormat);
                    //                            $(this).focus();

//                    return false;
                }
            }
        }
        catch (e) { }

    });

    $(".clsYear").attr("readonly", "readonly");
});

$(function () {
    $("input[type!='submit'], input[type!='button'], textarea").focusin(function () {
        $(this).css({ 'background-color': 'khaki' });
    });

    $("input[type!='submit'], input[type!='button'], textarea").blur(function () {
        $(this).css({ 'background-color': '' });
    });
});

/* New Added */

//var root = '/BPMigas.SINAS.Web.VS2010/';

//$.ajax({
//    url: root + 'js/helper.js',
//    dataType: "script"
//});

//$.getScript(root + 'js/helper.js', function (data, textStatus, jqxhr) {
//    console.log(data); //data returned
//    console.log(textStatus); //success
//    console.log(jqxhr.status); //200
//    console.log('Load was performed.');
//});
